import React from "react";
import View from "../base/View";
import defaultData from "./data";
import { _subTitle } from "../../../../common/check-length";
import { WeaInput, WeaLocaleProvider } from "ecCom";
import { isChecked } from '../../../../../utils/statusDetect';
const formatMultiLang = WeaLocaleProvider.formatMultiLang;

export default class InputView extends View {
  renderContent(data, value) {
    const { placeholder } = data;
    
    return (
      <WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@xpjgwz`}
        className='wea-edc-switch-input'
        value={value} 
        length={100} 
        onBlur={this.handleValueChange} 
        placeholder={formatMultiLang(placeholder)}
      />
    );
  }

  getSubTitle(data){
    let minV = 0;
    let maxV = 0;
    if (data.min && data.min.value){
      minV = isChecked(data.min.checked, data.min.value);
    }
    if (data.max && data.max.value){
      maxV = isChecked(data.max.checked, data.max.value);
    }
    return _subTitle(maxV,minV);
  }

}

InputView.defaultProps = {
  data: defaultData,
  value: ''
};